<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="author" content="lijun; 67086071; zwlijun@qq.com" />
<title>RIA Client API - BY 小网</title>
<link href="css/api.css" type="text/css" rel="stylesheet" />
</head>

<body>
  <ins>此文档描述Ajax对象的方法和属性</ins>
  <div class="nav">
    <a href="#parent">parent</a>
    <a href="#config">config</a>
    <a href="#Ajax">Ajax()</a>
    <a href="#sendRequest">sendRequest()</a>
    <a href="#clearCycle">clearCycle()</a>
  </div>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">parent属性<a name="parent"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>引用RIAClient对象</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>var parent = ajax.parent;</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>引用RIAClient对象</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var ajax = new Ajax();
var parent = ajax.parent;
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">config属性<a name="config"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>ajax参数配置</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>var config = ajax.config;</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>
<pre>
ajax参数配置
 * config.method            请求时用的方法,默认为 POST
 * config.asynch            是否为异步,默认为true
 * config.contentType       请求时的Content-Type
 * config.cache             是否缓存 默认为true
 * config.proxy             代理 默认为null
 * config.url               请求URL
 * config.param             参数
 * config.formName          表单名/表单对象
 * config.requestHeader     需要设置的http头
 * config.headerHandler     获取http头的处理函数
 * config.responseHeader    指定的http头
 * config.headerArgs        获取http头处理函数的参数。
 * config.handler           处理函数
 * config.args              处理函数参数
 * config.isXML             响应类型 true:xml false:text 默认为true
 * config.timeout           请求超时时间
 * config.interval          请求周期
 * config.tryTimes          请求失败时尝试次数
</pre>
        </td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var ajax = new Ajax();
var config = null;
config = ajax.config;
//config = ajax.getConfig();
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">Ajax构造方法<a name="Ajax"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>构造方法</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>var ajax = new Ajax();</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>构造方法</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var ajax = new Ajax();
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">sendRequest方法<a name="sendRequest"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>发送ajax请求</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>ajax.sendRequest(config)</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>发送ajax请求</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
function getData()
{
  var ajax = new Ajax();
  ajax.sendRequest({
    url:"data.html",
    handler:dealData,
    args:[],
    isXML:false,
    timeout:1
  });
}
function dealData()
{
  var args = arguments;
  var client = RIAClient;
  alert(args[0].status + "/" + args[0].data);
}
window.onload = getData;
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">clearCycle方法<a name="clearCycle"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>清除定时调用的定时器</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>ajax.clearCycle();</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>清除定时调用的定时器</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var ajax = new Ajax();
ajax.sendRequest({
  url:"data.html",
  handler:null,
  args:[],
  isXML:false,
  timeout:3000,
  interval:600000
});
function clear()
{
  ajax.clearCycle();
}
document.body.onclick = clear;
</pre>
        </td>
      </tr>
    </tbody>
  </table>
</body>
</html>